﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demos.DesignPatterns._22_状态模式
{
    /// <summary>
    /// 订单信息
    /// </summary>
    public class Order
    {
        private IOrderState _state;
        public string OrderId { get; }

        public Order(string orderId)
        {
            OrderId = orderId;
            _state = new CreatedState();
        }

        public void SetState(IOrderState state)
        {
            _state = state;
        }
        /// <summary>
        /// 处理订单
        /// </summary>
        public void Process() => _state.Process(this);
        /// <summary>
        /// 发货
        /// </summary>
        public void Ship() => _state.Ship(this);
        /// <summary>
        /// 配送
        /// </summary>
        public void Deliver() => _state.Deliver(this);
        /// <summary>
        /// 取消订单
        /// </summary>
        public void Cancel() => _state.Cancel(this);
    }
}
